import { configureStore } from "@reduxjs/toolkit";
import cart from "./redux_module/cart"
import setting from "./redux_module/setting"
import { persistReducer, persistStore } from "redux-persist"
import storage from 'redux-persist/lib/storage';

//持久化存储配置
const persistConfigCarts = {
    key: "carts",
    storage,
    whilelist: [] //
}

//持久化存储配置
const persistConfigSettings = {
    key: "setting",
    storage,
    whilelist: [] //
}

const persistedReducerCarts = persistReducer(persistConfigCarts, cart)
const persistedReducerSettings = persistReducer(persistConfigSettings, setting)

export const store = configureStore({
    reducer: {
        carts: persistedReducerCarts,
        setting: persistedReducerSettings
    },
    middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false })
})

export const persistor = persistStore(store)